from selenium.webdriver.common.by import By
from base.base import Base
from selenium.webdriver.support.ui import Select
import time

class Page_Report(Base):


    topnav_locator = (By.XPATH,'(//li[contains(@class,"ant-menu-overflow-item")])[6]')  
    input_time_locator = (By.XPATH,'//input[@placeholder="开始日期"]')
    month_locator = (By.XPATH,'(//button[@class="ant-picker-month-btn"])[1]')
    start_month_locator = (By.XPATH,'//div[@class="ant-picker-cell-inner" and text()="6月"]')
    start_day_locator = (By.XPATH,'(//div[text()="1"])[1]')
    end_day_locator = (By.XPATH,'(//div[text()="28"])[3]')
    select_btn_locator = (By.XPATH,'//span[text()="查 询"]')
    reset_btn_locator = (By.XPATH,'//span[text()="重 置"]')
    report_list_locator = (By.XPATH,'//tbody[@class="ant-table-tbody"]//td[contains(@class,"ant-table-cell")]')
    type_input_locator = (By.XPATH,'//div[@class="ant-select ant-select-single ant-select-allow-clear ant-select-show-arrow"]')
    type_locator = (By.XPATH,'//div[@class="ant-select-item-option-content"]')
    empty_prompt_locator = (By.CLASS_NAME,'ant-empty-description')



    def page_jump(self):
        self.click(self.topnav_locator)

    def click_time_inputbox(self):
        self.click(self.input_time_locator)

    def click_month_inputbox(self):
        self.click(self.month_locator)

    def select_start_month(self):
        self.click(self.start_month_locator)

    def select_start_day(self):
        self.click(self.start_day_locator)

    def select_end_day(self):
        self.click(self.end_day_locator)

    def click_select_btn(self):
        self.click(self.select_btn_locator)
    
    def click_reset_btn(self):
        self.click(self.reset_btn_locator)

    def get_reportlist(self):
        values = []
        elms = self.finds(self.report_list_locator)
        for index,elm in enumerate(elms):
            if index%4 != 3:
                values.append(self.get_text_elm(elm))
        return values

    def click_type_input(self):
        self.click(self.type_input_locator)

    def select_tpye(self,id = 0):
        elms = self.finds(self.type_locator)
        self.click(elms[id])

    def get_empty_info(self):
        return self.get_text(self.empty_prompt_locator)
    

